Skip to content

Conversation

@rtibbles
Copy link
Member

@rtibbles rtibbles commented Jan 5, 2026

Summary

When Language.id was changed from max_length=7 to max_length=14 in migration 0081, Django 1.9 did not cascade the primary key column size change to many-to-many junction table columns.

This migration fixes the included_languages through table language_id column for databases that were created before the migration squash. It is idempotent - columns that are already varchar(14) are not modified.

Fixes: contentcuration_channel_included_languages.language_id

Adds migration test that deliberately corrupts the DB columns then runs the migration and confirms the fix.

References

Fixes #5618

Reviewer guidance

Because of our migration squashing, the bug is not extant on development machines, so coercing the database column length manually and then running the migration to ensure the change in the migration test was the best I could do here.

🤖 This was created by Claude Code. @rtibbles then reviewed the generated output, and made updates before making it ready for review 🤖

@rtibbles rtibbles added this to the Studio: Patch Releases milestone Jan 5, 2026
@rtibbles rtibbles marked this pull request as draft January 6, 2026 00:00
@rtibbles
Copy link
Member Author

rtibbles commented Jan 6, 2026

And... of course I should have rerun the tests after rebasing...

When Language.id was changed from max_length=7 to max_length=14 in
migration 0081, Django 1.9 did not cascade the primary key column size
change to foreign key and many-to-many junction table columns.

This migration fixes those columns for databases that were created
before the migration squash. It is idempotent - columns that are
already varchar(14) are not modified.

Fixes: contentcuration_channel.language_id
Fixes: contentcuration_channel_included_languages.language_id
Fixes: contentcuration_contentnode.language_id
Fixes: contentcuration_file.language_id

Adds migration test that deliberately corrupts the DB columns
then runs the migration and confirms the fix.
@rtibbles rtibbles marked this pull request as ready for review January 6, 2026 00:04
@bjester bjester self-assigned this Jan 6, 2026
Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only column that is still limited to 7 characters is contentcuration_channel_included_languages.language_id. This makes sense because that's where the error occurred, and if a channel already included content for a language that exceeded the limit, that means a content node and file must already have it. I've confirmed, on every cloud instance DB, the aforementioned column is the only column named language_id that is less than 14 characters limit.

After verification on production servers, only the
contentcuration_channel_included_languages junction table is affected
by the varchar(7) issue. The other FK columns (channel.language_id,
contentnode.language_id, file.language_id) are already varchar(14).

This simplifies the migration to only fix the one affected column.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@rtibbles
Copy link
Member Author

Have updated with a follow up commit to narrow the scope here - left it as a follow up commit to make review easier, but we can squash merge this, as the first commit is not needed!

Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and verified. LGTM :shipit:

@bjester bjester merged commit 4f67e69 into learningequality:hotfixes Jan 13, 2026
15 checks passed
@rtibbles rtibbles deleted the m2m_lang branch January 13, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants